<template>
	<view>
		<!-- <u-navbar :is-back="false" title="首页" :background="{ background: '#ff0000' }" title-color="#fff" :border-bottom="false"></u-navbar> -->
		<!-- <u-navbar  title="" :background="{ background: '#ff0000' }" title-color="#fff" ></u-navbar> -->
		
		<view
			style="width:100%;height: 350rpx;background: linear-gradient(#f18f00, #f5a93c, #fce8c9);border-bottom-left-radius: 20rpx;border-bottom-right-radius: 20rpx;">
			<view style="height: 200rpx;"></view>
			<view style="width:90%;margin:0 auto;display: flex;align-items: center;padding-top: 20rpx">
				
				
				<view v-if="whatLogin == ''" class="" style="display: flex;align-items: center;">
					<image style="width: 100rpx;height: 100rpx;border-radius: 50%;" src="../../static/logo.png" mode=""></image>
					
					<view @click="goLogin" class="" style="margin-left: 30rpx;font-size: 50rpx;color: #fff;">
						去登录
					</view>
				</view>
				<view v-if="whatLogin != ''" class="" style="display: flex;align-items: center;">
					<image style="width: 100rpx;height: 100rpx;border-radius: 50%;" :src="tx" mode=""></image>
					<view class="" style="margin-left: 50rpx;">
						<view class="">
							{{mz}}
						</view>
						<view class="">
							ID:33333333
						</view>
					</view>
				<!-- 	<view class="qishou" @click="goRider">
						骑手端
					</view>
					 -->
				</view>
				
				
			</view>
		</view>
		
		<view style="width:96%;margin:0 auto;background: #fff;border-radius: 20rpx;margin-top: 20rpx;padding:20rpx 0rpx;">
			
			<view style="width:100%;display: flex;justify-content: space-around;align-items: center;padding-bottom: 20rpx;">
				<view class="tubiao" @click="gonewpage">
					<image src="../../static/daizhifu.png" style="width:60rpx;height: 60rpx;"></image>
					<view style="font-size: 26rpx;margin-top: 10rpx;">
						待支付
					</view>
				</view>
				<view class="tubiao" @click="gonewpage2">
					<image src="../../static/daipeisong.png" style="width:60rpx;height: 60rpx;"></image>
					<view style="font-size: 26rpx;margin-top: 10rpx;">
						待配送
					</view>
				</view>
				<view class="tubiao" @click="gonewpage1">
					<image src="../../static/card.png" style="width:60rpx;height: 60rpx;"></image>
					<view style="font-size: 26rpx;margin-top: 10rpx;">
						待确认
					</view>
				</view>
				
				<view class="tubiao" @click="gonewpage3">
					<image src="../../static/daipinglun.png" style="width:60rpx;height: 60rpx;"></image>
					<view style="font-size: 26rpx;margin-top: 10rpx;">
						待评论
					</view>
				</view>
				<view class="tubiao" @click="gonewpage4">
					<image src="../../static/yiwancheng.png" style="width:60rpx;height: 60rpx;"></image>
					<view style="font-size: 26rpx;margin-top: 10rpx;">
						已完成
					</view>
				</view>
			</view>
		</view>
		
		<view style="width:96%;margin:0 auto;background: #fff;border-radius: 20rpx;margin-top: 20rpx;padding:20rpx 0rpx;">
			<!-- <image src="../../static/arrow.png" style="width:30rpx;height: 30rpx;"></image> -->
			<view class="" style="display: flex;justify-content: space-between;padding: 20rpx;" @click="goYouhuiQuan">
				<view class="">
					优惠券
				</view>
				<u-icon name="arrow-right" color="#000" size="28"></u-icon>
			</view>
			<view class="" style="display: flex;justify-content: space-between;padding: 20rpx;" @click="goMyAddress">
				<view class="">
					我的地址
				</view>
				<u-icon name="arrow-right" color="#000" size="28"></u-icon>
			</view>
			<view class="" style="display: flex;justify-content: space-between;padding: 20rpx;" @click="goscDianpu">
				<view class="">
					收藏店铺
				</view>
				<u-icon name="arrow-right" color="#000" size="28"></u-icon>
			</view>
			<view class="" style="display: flex;justify-content: space-between;padding: 20rpx;" @click="goMypl">
				<view class="">
					我的评论
				</view>
				<u-icon name="arrow-right" color="#000" size="28"></u-icon>
			</view>
			
			<view v-if="is_store" class="" style="display: flex;justify-content: space-between;padding: 20rpx;" @click="goMyStore">
				<view class="">
					管理店铺
				</view>
				<u-icon name="arrow-right" color="#000" size="28"></u-icon>
			</view>
			
			
		</view>
		<view v-if="whatLogin != ''" class="loginOut" @click="loginOut">
			退出登录
		</view>
	</view>
</template>

<script>
	import login from '@/components/login.vue'
	import {
		mapActions,
		mapGetters
	} from 'vuex';
	export default {
		components:{
			login
		},
		computed: {
			...mapGetters(['userInfo', 'getOpenId'])
		},
		data() {
			return {
				phone:'',
				name:'',
				image:'',
				id:'',
				whatLogin:'',
				tx:'',
				mz:'',
				userId:'',
				MoneyShows:false,
				txMoney:'',
				bank_account:'',
				bank_name:'',
				bank_address:'',
				real_name:'',
				balance:'',
				yuer:'',
				is_store:'',
				
				
			}
		},
		onShow() {
			// this.getUserInfo()
			this.whatLogin = uni.getStorageSync('userId')
			this.hh()
			this.is_store = uni.getStorageSync('is_stor')
			this.yuer = uni.getStorageSync('balance')
		},
		onLoad() {
			this.hh()
			this.userId = uni.getStorageSync('userId')
			if (this.userId == '') {
				uni.navigateTo({
					url: '/login-pkg/login/login'
				})
			}
		},
		methods: {
			
			
			goLogin(){
				uni.navigateTo({
					url:'/login-pkg/login/login'
				})
			},
			
			
			//微信支付
			wxPay(res){
				let that = this
				wx.requestPayment({
					provider: 'wxpay', // 服务提提供商
					timeStamp: res.data.json.timeStamp, // 时间戳
					nonceStr: res.data.json.nonceStr, // 随机字符串
					package: res.data.json.package,
					signType: res.data.json.signType, // 签名算法
					paySign: res.data.json.paySign, // 签名
					success: function (res) {
						console.log('支付成功',res);
						// 业务逻辑。。。
						that.$store.dispatch('auth/getInfo', that.userInfo.id)
					},
					fail: function (err) {
						console.log('支付失败',err);
					}
				});		
			},
			
			hh(){
				this.tx = uni.getStorageSync('image')
				this.mz = uni.getStorageSync('name')
			},
			// 获取用户信息
			
			
			//退出登录
			loginOut() {
				uni.showLoading({
					title: '退出中'
				})
				wx.removeStorageSync('userId')
				wx.removeStorageSync('name')
				wx.removeStorageSync('image')
				wx.removeStorageSync('phone')
				this.whatLogin = ''
				
				
				setTimeout(() => {
					uni.hideLoading()
				}, 500)
			},
			goRider(){
				uni.navigateTo({
					url: '/rider-pkg/rider/rider'
				})
			},
			gonewpage(){
				uni.navigateTo({
					url: `/daipay-pkg/daipay/daipay?status=${0}`
				})
			},
			gonewpage1(){
				uni.navigateTo({
					url: `/daipay-pkg/daipay/daipay?status=${1}`
				})
			},
			gonewpage2(){
				uni.navigateTo({
					url: `/daipay-pkg/daipay/daipay?status=${4}`
				})
			},
			gonewpage3(){
				uni.navigateTo({
					url: `/daipay-pkg/daipay/daipay?status=${5}`
				})
			},
			gonewpage4(){
				uni.navigateTo({
					url: `/daipay-pkg/daipay/daipay?status=${6}`
				})
			},
			goYouhuiQuan(){
				uni.navigateTo({
					url: '/youhuiquan-pkg/youhuiquan/youhuiquan'
				})
			},
			goMyAddress(){
				uni.navigateTo({
					url: '/myaddress-pkg/myaddress/myaddress'
				})
			},
			goscDianpu(){
				uni.navigateTo({
					url: '/shoucangdp-pkg/shoucangdp/shoucangdp'
				})
			},
			goMypl(){
				uni.navigateTo({
					url: '/youhuiquan-pkg/mypl/mypl'
				})
			},
			goTx(){
				// moneyTi
				this.MoneyShows = true
			},
			noMoney(){
				this.MoneyShows = false
			},
			yesMoney(){
				this.$req('POST',this.$api.moneyTi,{
					user_id:uni.getStorageSync('userId'),
					store_id:uni.getStorageSync('storId'),
					amount:this.txMoney,
					bank_name:this.bank_name,
					bank_account:this.bank_account,
					bank_address:this.bank_address,
					real_name:this.real_name
					
					
				}).then(res =>{
					console.log(res,'查看提醒成功与否')
					if(res.status == 200){
						uni.$u.toast('提现申请成功')
						this.getUserInfo()
						this.txMoney = ''
						this.bank_name = ''
						this.bank_account = ''
						this.bank_address = ''
						this.real_name = ''
						this.MoneyShows = false
						
					}else{
						uni.$u.toast(res.message)
						this.txMoney = ''
						this.bank_name = ''
						this.bank_account = ''
						this.bank_address = ''
						this.real_name = ''
						this.MoneyShows = false
					}
					
				})
				
				
			},
			getUserInfo(){
				this.$req('GET',this.$api.getUser,{
					id:uni.getStorageSync('userId')
				}).then(ress =>{
					
					this.balance = ress.data.store.balance
					
					uni.setStorageSync('balance',this.balance)
					this.yuer = uni.getStorageSync('balance')
				})
			},
			goMyStore(){
				uni.navigateTo({
					url: '/free-pkg/mystore/mystore'
				})
			}
			
		}
	}
</script>

<style>
	page {
		background: #eee;
	}
	.loginOut {
		width: 92%;
		height: 85rpx;
		line-height: 85rpx;
		margin: 200rpx auto;
		font-size: 32rpx;
		text-align: center;
		color: #fff;
		border-radius: 16rpx;
		background-color: #E04D19;
		margin-top: 200rpx;
	}
	.vipCard {
		width: 622rpx;
		height: 160rpx;
		padding: 0 32rpx;
		margin: 20rpx auto;
		display: flex;
		justify-content: space-between;
		align-items: flex-start;
		/* background-image: url('@/static/vipCard.png'); */
		background-size: 100% 100%;
	}
	.left{
		color: #FFFFFF;
		line-height: 160rpx;
	}
	.vt2 {
		height: 64rpx;
		line-height: 64rpx;
		text-align: center;
		border-radius: 30rpx;
		/* background-image: url('@/static/vipBtn.png'); */
		background-size: 100% 100%;
		font-size: 28rpx;
		font-weight: 500;
		color: #000000;
		margin-top: 48rpx;
	}
	
	.tubiao{
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}
	
	.qishou{
		width: 150rpx;
		height: 60rpx;
		background-color: rgba(224,77,25);
		margin-left: 40rpx;
		text-align: center;
		line-height: 60rpx;
		color: #fff;
		border-radius: 30rpx;
	}
	
</style>
